CC:=gcc
CFLAGS:= -g -O0 -Wall  # 添加调试信息并禁用优化

log:=thirdparty/log.c thirdparty/log.h

test_log: test/test_log.c $(log)
	$(CC) $(CFLAGS) -o test_log test/test_log.c $(log) -Ithirdparty/
#	./test_log
#	rm test_log

json:=thirdparty/cJSON.c thirdparty/cJSON.h

test_json: test/test_json.c $(json) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/
	./$@
	rm $@

common:=app/app_common.c app/app_common.h
test_common: test/test_common.c $(common) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

message:=app/app_message.c app/app_message.h
test_message: test/test_message.c $(message) $(common) $(log) $(json)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

mqtt:=app/app_mqtt.c app/app_mqtt.h
test_mqtt:test/test_mqtt.c $(mqtt)     $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/   -lpaho-mqtt3c
	./test_mqtt
	rm test_mqtt

pool:=app/app_pool.c app/app_pool.h
test_pool:test/test_pool.c $(pool)  $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

buffer:=app/app_buffer.c app/app_buffer.h
test_buffer:test/test_buffer.c $(buffer)  $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

device:=app/app_device.c app/app_device.h
bt:= app/app_bt.c app/app_bt.h
test_device:test/test_device.c $(device)  $(log) $(common) $(message) $(mqtt) $(pool) $(buffer) $(json) $(bt)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/ -lpaho-mqtt3c
	./$@
	rm $@